package com.lancoo.cvas.pojo.constant;

import com.lancoo.cvas.pojo.response.basicPlatform.SubSystemsMainServer;
import com.lancoo.cvas.service.YunService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.ResourceUtils;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.io.FileNotFoundException;
import java.util.*;

@Component
@Slf4j
public class GlobalConstant {
    @Resource
    private YunService yunService;

    public final static String REDIS_PREFIX = "cvas:";
    public final static String REDIS_ROUND_KEY = "cvas:round";

    public static String LOCAL_PATH;

    public static String SERVER_PORT;
    public static String SERVER_PATH;
    //后端访问路径
    public static String ACCESS_PATH;


    public static String OUTPUT_EXCEL_PATH;

    public static String MODEL_EXCEL_PATH;

    public static String ErrorImportMsg_EXCEL_PATH;

    public static List<String> dayCode = new ArrayList<>(Arrays.asList("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14"));
    public static List<String> dayName = new ArrayList<>(Arrays.asList("星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"));
    public static Map<Integer, String> roomTypeMap = new HashMap<>();
    public static Map<Integer, String> roomTypeMap2 = new HashMap<>();

    public static Map<Integer, String> roomTypeMap3 = new HashMap<>();
    public static Map<String, String> dayNameCodeMap = new HashMap<>();
    public static Map<Integer, String> hourTypeMap = new HashMap<>();
    public static Map<String, String> operationTypeMap = new HashMap<>();
    public static Map<Integer, String> processOperationTypeMap = new HashMap<>();


    static {
        dayNameCodeMap.put("01", "星期一");
        dayNameCodeMap.put("02", "星期二");
        dayNameCodeMap.put("03", "星期三");
        dayNameCodeMap.put("04", "星期四");
        dayNameCodeMap.put("05", "星期五");
        dayNameCodeMap.put("06", "星期六");
        dayNameCodeMap.put("07", "星期日");
        dayNameCodeMap.put("08", "星期一");
        dayNameCodeMap.put("09", "星期二");
        dayNameCodeMap.put("10", "星期三");
        dayNameCodeMap.put("11", "星期四");
        dayNameCodeMap.put("12", "星期五");
        dayNameCodeMap.put("13", "星期六");
        dayNameCodeMap.put("14", "星期日");

        roomTypeMap.put(11, "云网络教室");
        roomTypeMap.put(21, "A1智慧教室");
        roomTypeMap.put(22, "传统多媒体教室");
        roomTypeMap.put(23, "云演播室");
        roomTypeMap.put(24, "多媒体智慧教室");
        roomTypeMap.put(31, "普通电脑室");
        roomTypeMap.put(32, "2018c语音室");
        roomTypeMap.put(45, "运动场");
        roomTypeMap.put(46, "实验室");
        roomTypeMap.put(411, "游泳馆");
        roomTypeMap.put(412, "篮球场");
        roomTypeMap.put(413, "足球场");
        roomTypeMap.put(414, "羽毛球场");
        roomTypeMap.put(415, "乒乓球台");
        roomTypeMap.put(416, "练琴房");
        roomTypeMap.put(417, "舞蹈房");
        roomTypeMap.put(418, "体测室");
        roomTypeMap.put(48763,"自定义类型教室");

        roomTypeMap2.put(11, "云网络教室");
        roomTypeMap2.put(21, "A1智慧教室");
        roomTypeMap2.put(22, "传统多媒体教室");
        roomTypeMap2.put(23, "云演播室");
        roomTypeMap2.put(24, "多媒体智慧教室");
        roomTypeMap2.put(31, "普通电脑室");
        roomTypeMap2.put(32, "语音室");
        roomTypeMap2.put(45, "操场/体育场所");
        roomTypeMap2.put(46, "实验室");

        roomTypeMap3.put(11, "云网络教室");
        roomTypeMap3.put(21, "A1智慧教室");
        roomTypeMap3.put(22, "传统多媒体教室");
        roomTypeMap3.put(23, "云演播室");
        roomTypeMap3.put(24, "多媒体智慧教室");
        roomTypeMap3.put(31, "普通电脑室");
        roomTypeMap2.put(46, "实验室");
        roomTypeMap3.put(32, "2018c语音室");
        roomTypeMap3.put(12, "云办公室");
        roomTypeMap3.put(410, "会议室");
        roomTypeMap3.put(44, "宿舍");
        roomTypeMap3.put(45, "运动场");
        roomTypeMap3.put(49, "阅览室");
        roomTypeMap3.put(411, "游泳馆");
        roomTypeMap3.put(412, "篮球场");
        roomTypeMap3.put(413, "足球场");
        roomTypeMap3.put(414, "羽毛球场");
        roomTypeMap3.put(415, "乒乓球房");
        roomTypeMap3.put(416, "练琴房");
        roomTypeMap3.put(417, "舞蹈房");
        roomTypeMap3.put(418, "体测室");
        roomTypeMap3.put(47, "校门口");
        roomTypeMap3.put(48, "楼道");


        hourTypeMap.put(0, "环节");
        hourTypeMap.put(1, "讲授");
        hourTypeMap.put(2, "实验");
        hourTypeMap.put(3, "上机");
        hourTypeMap.put(4, "其他");

        operationTypeMap.put("1", "新建");
        operationTypeMap.put("2", "编辑");
        operationTypeMap.put("3", "查看");
        operationTypeMap.put("4", "删除");
        operationTypeMap.put("5", "提交");
        operationTypeMap.put("6", "审核");
        operationTypeMap.put("7", "撤回");
        operationTypeMap.put("8", "发布");
        operationTypeMap.put("13", "上传");
        operationTypeMap.put("14", "下载");
        operationTypeMap.put("15", "启用");
        operationTypeMap.put("16", "禁用");

        processOperationTypeMap.put(1, "2");
        processOperationTypeMap.put(2, "2");
        processOperationTypeMap.put(3, "2");
        processOperationTypeMap.put(4, "2");
        processOperationTypeMap.put(5, "13");
        processOperationTypeMap.put(6, "5");
        processOperationTypeMap.put(7, "2");
        processOperationTypeMap.put(8, "2");
        processOperationTypeMap.put(9, "2");
        processOperationTypeMap.put(10, "5");
        processOperationTypeMap.put(11, "2");
        processOperationTypeMap.put(12, "1");
        processOperationTypeMap.put(13, "1");
        processOperationTypeMap.put(14, "1");
        processOperationTypeMap.put(15, "5");
        processOperationTypeMap.put(16, "5");
        processOperationTypeMap.put(17, "8");
        processOperationTypeMap.put(18, "8");
        processOperationTypeMap.put(19, "8");
        processOperationTypeMap.put(20, "8");

        try {
            LOCAL_PATH = ResourceUtils.getFile("classpath:").getPath();
            OUTPUT_EXCEL_PATH = LOCAL_PATH + "\\static\\OutputExcel\\";
            MODEL_EXCEL_PATH = LOCAL_PATH + "\\static\\ExcelModel\\";
            ErrorImportMsg_EXCEL_PATH = LOCAL_PATH + "\\static\\ErrorImportMsg\\";
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

    }

    @PostConstruct
    private void initParam() {
        try {
            SubSystemsMainServer e31 = yunService.getSubSystemsMainServer("E31", false);
            GlobalConstant.ACCESS_PATH = e31.getWsSvrAddr();
        } catch (Exception e) {
            log.warn("获取服务器地址失败，1min后重试...");

        }
    }

}
